# -*- coding: utf-8 -*-
import os

from PyQt4.QtCore import QMetaObject
from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QPixmap

from config.preferences import SRC_PATH


class ShowImage(QGraphicsView):

    def __init__(self, parent = None, origPixmap = None):
        """
        
        """
        super(ShowImage, self).__init__(parent)
        QMetaObject.connectSlotsByName(self)
        self.origPixmap = origPixmap



    def previewImage(self):
        """
        
        """
        os.chdir(SRC_PATH + '/tmp/')
        pic = QPixmap('plot.jpg')
        self.grview = ShowImage(origPixmap = pic)
        scene = QGraphicsScene()
        scene.addPixmap(pic)
        self.grview.setMinimumHeight(900)
        self.grview.setMinimumWidth(700)
        self.grview.setMaximumHeight(1200)
        self.grview.setMaximumWidth(1000)
        self.grview.setScene(scene)
        self.grview.setWindowTitle("Imagem")
        self.grview.setVisible(True)
        self.grview.show()
        os.chdir(SRC_PATH)



    def closeImage(self):
        """
        
        """
        self.grview.close()
